package com.huchao.www.dao;

import com.huchao.www.pojo.LockInfo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.Date;


/**
 * @Description:
 * @BelongsProject: springMVC
 * @BelongsPackage: com.huchao.www.dao
 * @Author: 亖思
 * @CreateTime: 2022/12/8 20:47
 * @Version: 1.0
 */
@Mapper
public interface LockMapper {
    /**
     * 〈修改锁定信息〉
     * @param lockStatus:锁定状态
     * @param failCount:失败次数
     * @param lockerTime:最后一次失败时间
     * @param lockerTime:登录的用户名
     * @Author: 亖思
     * @Date: 2022/12/8 19:59
     * @return: boolean
     **/
    @Update("update lock_info set lock_status = #{lockStatus},fail_count = #{failCount} ,locked_time = #{lockerTime} where login_name = #{LoginName}")
    boolean updateLockInfoByLoginName(@Param("lockStatus") int lockStatus, @Param("failCount") int failCount, @Param("lockerTime") Date lockerTime, @Param("LoginName") String LoginName);

    /**
     * 〈根据loginName查找〉
     * @param loginName:loginName
     * @Author: 亖思
     * @Date: 2022/12/8 20:54
     * @return: LockInfo
     **/
    @Select("select * from lock_info where login_name = #{loginName} ")
    @Results({
            @Result(id = true,property = "loginName",column = "login_name"),
            @Result(property = "lockStatus",column = "lock_status"),
            @Result(property = "failCount",column = "fail_count"),
            @Result(property = "lockedTime",column = "locked_time",jdbcType = JdbcType.TIMESTAMP)
    })
    LockInfo findByLoginName(@Param("loginName") String loginName);

    /**
     * 〈增加〉
     * @param loginName:
     * @Author: 亖思
     * @Date: 2022/12/8 21:06
     * @return: void
     **/
    @Insert("insert into lock_info(login_name) values(#{loginName})")
    void insertNewInfo(@Param("loginName") String loginName);
}
